// Copyright (C) 2023 Focus Media Holding Ltd. All Rights Reserved.

package com.lb.base.util;

import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Formatter;
import java.util.List;

import cn.hutool.core.collection.ListUtil;

/**
 * TODO
 *
 * @author libin
 * @version V1.0
 * @since 2023-06-15 17:38
 **/
public class Play {

    private static final String MD5_ALGORITHM = "MD5";

    public static String encrypt(String data) throws Exception {
        // 获取MD5算法实例
        MessageDigest messageDigest = MessageDigest.getInstance(MD5_ALGORITHM);
        // 计算散列值
        byte[] digest = messageDigest.digest(data.getBytes());
        Formatter formatter = new Formatter();
        // 补齐前导0，并格式化
        for (byte b : digest) {
            formatter.format("%02x", b);
        }
        return formatter.toString();
    }

    public static void main(String[] args) throws Exception {

//        String data = "Hello World";
//        String encryptedData = encrypt(data);
//        System.out.println("加密后的数据：" + encryptedData);

        List<String> list = new ArrayList<>();
        list.add("a");

        List<List<String>> splitAvg = ListUtil.splitAvg(list, 2);
        splitAvg.forEach(System.out::println);
    }

}